{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  {if $doSubmit == 1}
    bookFunction();
  {/if}
});

function deleteRow(bulliondetailid)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "bullionDelete.php?bulliondetailid="+bulliondetailid;
  }
}
</script>
<script type="text/javascript">
function bookFunction(id)
{
  document.form1.bdate.value="1";
  document.form1.submit();
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>{$l_bullionDetail}</h4></center>
<div class="contentDiv">
  <table border="1" align="center" width="100%" cellspacing="0" cellpadding="0">
  
  <tr>
    <td colspan="3" class="table1">
      {$l_partySelect} : 
      <select name="party"  onchange="bookFunction()">
        {html_options values=$party.partyId output=$party.bullionPartyName selected={$partyId}}
      </select>
    </td>
    {if $doSubmit == 1}
    <td colspan="9" class="table1" nowrap>
      {$l_from} : 
      {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$fromDate}}
      {$l_to} 
      {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$toDate}}
    </td>
    {/if}
    <td class="table1" align="center" colspan="5"><input type="submit" name="submitBtn" value="{$l_find}" /></td>
    {if $smarty.get.print != 1}
      <td class="table1"><a href="bullionDetail.php?print=1">{$l_bullionPrint}</a></td>
    {else}
      &nbsp;
    {/if}
   
  </tr>
  <tr class="table1">
    <th>&nbsp;</th>
    <th align="right">Date</th>
    <th align="right">{$l_particulars}</th>
    <th align="right">{$l_kg}</th>
    <th align="right">{$l_bhav}</th>
    <th align="right">{$l_cramount}</th>
    <th align="right">{$l_crfine}</th>
    <th align="right">{$l_dramount}</th>
  </tr>
  <tr class="table2">
    <td>&nbsp;</td>
    <td align="right">{$opening.particulars}</td>
    <td align="right">{if $opening.kg != 0}{$opening.kg|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.bhav != 0}{$opening.bhav|string_format:"%.2f"}{/if}</td>
    <td align="right">{if $opening.cramount != 0}{$opening.cramount|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.crfine != 0}{$opening.crfine|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.dramount != 0}{$opening.dramount|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.totalAmt}{$opening.totalAmt|string_format:"%..0f"}{/if}</td>
  </tr>
  {section name="sec" loop=$bullionDetail}
  <tr class="table2">
    <td>
      {if $smarty.get.print != 1}
      {if $bullionDetail[sec].bullionmasterid != $bullionDetail[$smarty.section.sec.index-1].bullionmasterid}<a href="bullionDetailList.php?print=1&bullionmasterid={$bullionDetail[sec].bullionmasterid}&partyId={$bullionDetail[sec].partyId}&bulliondate={$bullionDetail[sec].bulliondate}">Print</a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
     <a href="javascript:deleteRow({$bullionDetail[sec].bulliondetailid})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>
        <a href="bullionEntry.php?bullionmasterid={$bullionDetail[sec].bullionmasterid}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>
      {else}
        &nbsp;
      {/if}
    </td>
    <td align="right" style="border-right:1px solid;" NOWRAP>{$bullionDetail[sec].bulliondate|date_format:"%d-%m-%Y"}</td>
    <td align="right" style="border-right:1px solid;">{$bullionDetail[sec].particulars}</td>
    <td align="right" style="border-right:1px solid;">{if $bullionDetail[sec].kg != 0}{$bullionDetail[sec].kg|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px solid;">{if $bullionDetail[sec].bhav != 0}{$bullionDetail[sec].bhav|string_format:"%.2f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px solid;">{if $bullionDetail[sec].cramount != 0}{$bullionDetail[sec].cramount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px solid;">{if $bullionDetail[sec].crfine != 0}{$bullionDetail[sec].crfine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px solid;">{if $bullionDetail[sec].dramount != 0}{$bullionDetail[sec].dramount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
  </tr>
  </tr>
  {/section}
  <tr>
    <td colspan="10"><hr/></td>
  </tr>
  <tr class="table1">
     <th>&nbsp;</th>
     <th>&nbsp;</th>
      <th align="right">Total&nbsp;&nbsp;&nbsp;</th>
      <th align="right">{$total.kg|string_format:"%.0f"}</th>
      <th>&nbsp;</th>
      <th align="right" style="color:red;">{$total.cramount|string_format:"%.0f"}</th>
      <th align="right">{$total.crfine|string_format:"%.0f"}</th>
      <th align="right" style="color:green;">{$total.dramount|string_format:"%.0f"}</th>
  </tr>
   <tr>
    <td><b style="color:green;">{if $total.netfine >= 0} Total Debit Fine:{else}</b><b style="color:red;"> Total Credit Fine:{/if} {$total.netfine|string_format:"%.0f"}</b></td>
    <td><b style="color:green;">{if $total.netamount >= 0} Total Debit Fine:{else}</b><b style="color:red;"> Total Credit Fine:{/if} {$total.netamount|string_format:"%.0f"}</b></td>
  </tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
